﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Pages/Site.Master" AutoEventWireup="true"
    CodeBehind="Handle.aspx.cs" Inherits="_1041345_1041368_1041422_DoAnCuoiKy.Pages.Handle" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <%--Thư viện sử dụng Ajax--%>
    <script src="../Scripts/Lib/jquery_1.7.1.js" type="text/javascript"></script>
    <%--Thư viện sử dụng jQuery--%>
    <script src="../Scripts/Lib/jquery.alerts.js" type="text/javascript"></script>
    <script src="../Scripts/Lib/jquery.ui.draggable.js" type="text/javascript"></script>
    <script src="../Scripts/Lib/jquery.ui.dialog.js" type="text/javascript"></script>
    <script src="../Scripts/Lib/jquery.simplemodal.js" type="text/javascript"></script>
    <%--Thư viện CSS cho jQuery--%>
    <link href="../Styles/jquery.alerts.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function Delete()
        {
            var a = window.location.href.toString().split('?');
            var b = a[1].split('&');
            var temp = b[1].split('=');
            var ID = temp[1].toString();
            var str = b[2].split('=');
            $.ajax(
            {
                type: "GET",
                url: "http://localhost:9999/Service1.svc/Delete/" + str[1].toString(),
                dataType: "xml",
                success: function (xml) 
                {
                    window.location = "../Pages/Individual.aspx?ID=" + ID;
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert("Error Load Feed !!!" + textStatus + jqXHR + errorThrown);
                }
            });
        }

        function Update() 
        {
            var a = window.location.href.toString().split('?');
            var b = a[1].split('&');
            var temp = b[1].split('=');
            var ID = temp[1].toString();
            var str = b[2].split('=');            
            $.ajax(
            {
                type: "GET",
                url: "http://localhost:9999/Service1.svc/Update/" + ID.toString() + "/",
                dataType: "xml",
                success: function (xml) 
                {
                    window.location = "../Pages/Individual.aspx?ID=" + ID;
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert("Error Load Feed !!!" + textStatus + jqXHR + errorThrown);
                }
            });
        }

        function Handle() 
        {
            var a = window.location.href.toString().split('?');
            var b = a[1].split('&');
            var str = b[0].split('=');
            if (str[1].toString() == "Delete")
                Delete();
            else
                Update();
        }
    </script>

    <script type="text/javascript">
        Handle();
    </script>
</asp:Content>
